import { Column, Table } from '@zxhhyj/storm';

export interface Song {
  id?: number
  songName: string
  data: string
  coverUrl?: string
  albumName?: string
  artistName?: string
  duration?: number
  dateModified: number
  size: number
  bitrate?: number
  sampleRate?: number
  channels: number
  bitDepth?: number
  lyric?: string
  encoder?: string
  genre?: string
}

export class SongTable extends Table<Song> {
  readonly tableName = 't_song'
  // 核心标识字段
  readonly id = Column.integer('id').primaryKey(true).bindTo(this, 'id')
  readonly songName = Column.text('song_name').bindTo(this, 'songName')
  readonly data = Column.text('data').notNull().bindTo(this, 'data')
  // 媒体元数据
  readonly coverUrl = Column.text('cover_url').bindTo(this, 'coverUrl')
  readonly albumName = Column.text('album_name').bindTo(this, 'albumName')
  readonly artistName = Column.text('artist_name').bindTo(this, 'artistName')
  readonly duration = Column.integer('duration').bindTo(this, 'duration')
  readonly dateModified = Column.integer('date_modified').bindTo(this, 'dateModified')
  readonly size = Column.integer('size').bindTo(this, 'size')
  readonly bitrate = Column.integer('bitrate').bindTo(this, 'bitrate')
  readonly sampleRate = Column.integer('sample_rate').bindTo(this, 'sampleRate')
  readonly channels = Column.integer('channels').bindTo(this, 'channels')
  readonly bitDepth = Column.integer('bit_depth').bindTo(this, 'bitDepth')
  readonly lyric = Column.text('lyric').bindTo(this, 'lyric')
  readonly encoder = Column.text('encoder').bindTo(this, 'encoder')
  readonly genre = Column.text('genre').bindTo(this, 'genre')
}

export const songTable = new SongTable()